package org.game.db.dao;

import com.sojoys.artifact.manager.DataSourceManager;
import java.sql.Connection;
import com.sojoys.artifact.build.data.base.BaseDao;
import java.util.ArrayList;
import com.sojoys.artifact.manager.JsonManager;
import java.sql.SQLException;
import com.google.common.collect.Lists;
import com.xiaoleilu.hutool.util.ClassUtil;
import com.sojoys.artifact.tools.ToolMap;
import org.apache.commons.dbutils.handlers.MapHandler;
import com.sojoys.artifact.tools.SK_Plus;
import java.sql.ResultSet;
import java.util.Map;
import javax.sql.DataSource;
import org.apache.commons.dbutils.handlers.MapListHandler;
import com.sojoys.artifact.constant.CreateTableEnum;
import com.sojoys.artifact.constant.DataModelKeyEnum;
import org.apache.commons.dbutils.handlers.AbstractListHandler;
import org.apache.commons.dbutils.QueryRunner;
import com.xiaoleilu.hutool.log.Log;
import java.util.Set;
import com.sojoys.artifact.constant.ArtifactErrorCode;
import com.xiaoleilu.hutool.util.StrUtil;
import com.sojoys.artifact.tools.ToolError;
import org.apache.commons.dbutils.DbUtils;
import com.xiaoleilu.hutool.log.LogFactory;
import java.util.List;
import static org.game.db.StaticResource.PlayerResource.*;
import com.alibaba.fastjson.JSONObject;
import org.game.db.bean.Player;
import org.apache.commons.dbutils.ResultSetHandler;
import com.google.common.base.Joiner;
import static org.game.db.StaticResource.PlayerResource.*;
/**
 * 玩家
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public class PlayerDaoImpl implements BaseDao<Integer,Player>{
	static Log log = LogFactory.get(PlayerDaoImpl.class);
	
	// 代理
	
	/**
	 * 私有化无参构造方法
	 */
	private PlayerDaoImpl() {}
	  
    private static final PlayerDaoImpl INSTANCE = new PlayerDaoImpl();  
    
    public static PlayerDaoImpl me() {  
        return INSTANCE;  
    }  
	
	public Player insert(Player player){
		Connection conn = DataSourceManager.me().getMainConnection();
		return insert(player,conn);
	}
	
	public Player insert(Player player,Connection conn){
		return insert(player,conn,TABLE_NAME);
	}
	
	public Player insert(Player player,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return insert(player,conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public Player insert(Player player,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return insert(player,conn,tableName);
	}
	
	public Player insert(Player player,Connection conn,String tableName){
		
		QueryRunner run = new QueryRunner();
		String sql = "INSERT INTO " +tableName+ " (id,create_date,modified_date,uid,language,name,last_login_time,level,exp,vip_level,vip_exp,remark,pre,register_date,recharge_total_diamond) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
		try {
			int i = run.update(conn,sql,player.getId(),player.getCreateDate(),player.getModifiedDate(),player.getUid(),player.getLanguage(),player.getName(),player.getLastLoginTime(),player.getLevel(),player.getExp(),player.getVipLevel(),player.getVipExp(),player.getRemark(),player.isPre(),player.getRegisterDate(),player.getRechargeTotalDiamond());
			return i > 0 ? player : null;
		} catch (Exception e) {
			log.error(e);
			return null;
		} finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
	}
	
	public Player insert(Player player,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return insert(player,conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}		
	}
	
	public int[] insertBatch(List<Player> players){
		Connection conn = DataSourceManager.me().getMainConnection();
		return insertBatch(players,conn);
	}
	
	public int[] insertBatch(List<Player> players,Connection conn){
		return insertBatch(players,conn,TABLE_NAME);
	}
	
	public int[] insertBatch(List<Player> players,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return insertBatch(players,conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public int[] insertBatch(List<Player> players,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return insertBatch(players,conn,tableName);
	}
	
	public int[] insertBatch(List<Player> players,Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "INSERT INTO " +tableName+ " (id,create_date,modified_date,uid,language,name,last_login_time,level,exp,vip_level,vip_exp,remark,pre,register_date,recharge_total_diamond) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
		try {
			int columnSize = 15;
			int size = players.size();
			Object[][] params = new Object[size][columnSize];
			for (int i = 0; i < size; i++) {
				params[i][0] =players.get(i).getId();
				params[i][1] =players.get(i).getCreateDate();
				params[i][2] =players.get(i).getModifiedDate();
				params[i][3] =players.get(i).getUid();
				params[i][4] =players.get(i).getLanguage();
				params[i][5] =players.get(i).getName();
				params[i][6] =players.get(i).getLastLoginTime();
				params[i][7] =players.get(i).getLevel();
				params[i][8] =players.get(i).getExp();
				params[i][9] =players.get(i).getVipLevel();
				params[i][10] =players.get(i).getVipExp();
				params[i][11] =players.get(i).getRemark();
				params[i][12] =players.get(i).isPre();
				params[i][13] =players.get(i).getRegisterDate();
				params[i][14] =players.get(i).getRechargeTotalDiamond();
			}
			int[] is = run.batch(conn,sql,params);
			return is.length > 0 ? is : new int[]{};
		} catch (Exception e) {
			log.error(e);
			return new int[]{};
		} finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
	}
	
	public int[] insertBatch(List<Player> players,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return insertBatch(players,conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}		
	}
	
	public Player update(Player player){
		Connection conn = DataSourceManager.me().getMainConnection();
		return update(player,conn);
	}
	
	public Player update(Player player,Connection conn){
		return update(player,conn,TABLE_NAME);
	}
	
	public Player update(Player player,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return update(player,conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public Player update(Player player,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return update(player,conn,tableName);
	}
	
	public Player update(Player player,Connection conn,String tableName){
		List<Player> players = new ArrayList<Player>();
		players.add(player);
		updateBatch(players,conn,tableName);
		return player;
	}
	
	public Player update(Player player,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return update(player,conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public int[] updateBatch(List<Player> players){
		Connection conn = DataSourceManager.me().getMainConnection();
		return updateBatch(players,conn);
	}
	
	public int[] updateBatch(List<Player> players,Connection conn){
		return updateBatch(players,conn,TABLE_NAME);
	}
	
	public int[] updateBatch(List<Player> players,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return updateBatch(players,conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public int[] updateBatch(List<Player> players,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return updateBatch(players,conn,tableName);
	}
	
	public int[] updateBatch(List<Player> players,Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "UPDATE " +tableName+ " SET id = ?,create_date = ?,modified_date = ?,uid = ?,language = ?,name = ?,last_login_time = ?,level = ?,exp = ?,vip_level = ?,vip_exp = ?,remark = ?,pre = ?,register_date = ?,recharge_total_diamond = ? WHERE id = ?";
		try {
			int columnSize = 15;
			int size = players.size();
			Object[][] params = new Object[size][columnSize + 1];
			for (int i = 0; i < size; i++) {
				params[i][0] =players.get(i).getId();
				params[i][1] =players.get(i).getCreateDate();
				params[i][2] =players.get(i).getModifiedDate();
				params[i][3] =players.get(i).getUid();
				params[i][4] =players.get(i).getLanguage();
				params[i][5] =players.get(i).getName();
				params[i][6] =players.get(i).getLastLoginTime();
				params[i][7] =players.get(i).getLevel();
				params[i][8] =players.get(i).getExp();
				params[i][9] =players.get(i).getVipLevel();
				params[i][10] =players.get(i).getVipExp();
				params[i][11] =players.get(i).getRemark();
				params[i][12] =players.get(i).isPre();
				params[i][13] =players.get(i).getRegisterDate();
				params[i][14] =players.get(i).getRechargeTotalDiamond();
				params[i][columnSize] =players.get(i).getId();
			}
			int[] is = run.batch(conn,sql,params);
			return is.length > 0 ? is : new int[]{};
		} catch (Exception e) {
			log.error(e);
			return new int[]{};
		} finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
	}
	
	public int[] updateBatch(List<Player> players,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return updateBatch(players,conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}		
	}
	
	public boolean delete(Player player){
		Connection conn = DataSourceManager.me().getMainConnection();
		return delete(player,conn);
	}
	
	public boolean delete(Player player,Connection conn){
		return delete(player,conn,TABLE_NAME);
	}
	
	public boolean delete(Player player,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return delete(player,conn);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	public boolean delete(Player player,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return delete(player,conn,tableName);
	}
	
	public boolean delete(Player player,Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "DELETE FROM " + tableName + " WHERE id = ?";
		try {
			int i = run.update(conn,sql, player.getId());
			return i > 0 ? true : false;
		} catch (Exception e) {
			log.error(e);
			return false;
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return false;
			}
		}
	}
	
	public boolean delete(Player player,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return delete(player,conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	
	public boolean deleteBatch(List<Player> players){
		Connection conn = DataSourceManager.me().getMainConnection();
		return deleteBatch(players,conn);
	}
	
	public boolean deleteBatch(List<Player> players,Connection conn){
		return deleteBatch(players,conn,TABLE_NAME);
	}
	
	public boolean deleteBatch(List<Player> players,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return deleteBatch(players,conn);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	public boolean deleteBatch(List<Player> players,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return deleteBatch(players,conn,tableName);
	}
	
	public boolean deleteBatch(List<Player> players,Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "DELETE FROM " + tableName + " WHERE id = ?";
		try {
			int size = players.size();
			Object[][] params = new Object[size][1];
			for (int i = 0; i < size; i++) {
				params[i][0] = players.get(i).getId();
			}
			int[] is = run.batch(conn,sql,params);
			return is.length > 0;
		} catch (Exception e) {
			log.error(e);
			return false;
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return false;
			}
		}
	}
	
	public boolean deleteBatch(List<Player> players,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return deleteBatch(players,conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}

	/**
	 * 根据( id ) 查询
	 */
	public Player getById(int id){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getById(id, conn);
	}
	
	public Player getById(int id,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getById(id, conn,tableName);
	}
	public List<Player> getIn(Set<Integer> ids){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getIn(ids, conn);
	}
	
	public List<Player> getIn(Set<Integer> ids,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getIn(ids, conn,tableName);
	}
	/**
	 * 根据( uid ) 查询
	 */
	public Player getByUid(String uid){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getByUid(uid, conn);
	}
	
	public Player getByUid(String uid,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getByUid(uid, conn,tableName);
	}
	/**
	 * 根据( pre ) 查询
	 */
	public List<Player> getByPre(boolean pre){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getByPre(pre, conn);
	}
	
	public List<Player> getByPre(boolean pre,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getByPre(pre, conn,tableName);
	}
	
	public List<Player> getByPagePre(boolean pre,int page,int pageSize){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getByPagePre(pre, conn,page,pageSize);
	}
	
	public List<Player> getByPagePre(boolean pre,String tableName,int page,int pageSize){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getByPagePre(pre, conn,tableName,page,pageSize);
	}
	
	//Connection
	/**
	 * 根据( id ) 查询
	 */
	public Player getById(int id,Connection conn){
		return getById(id,conn,TABLE_NAME);
	}
	
	public Player getById(int id,Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "SELECT id,create_date,modified_date,uid,language,name,last_login_time,level,exp,vip_level,vip_exp,remark,pre,register_date,recharge_total_diamond FROM " + tableName + " WHERE " + "id = ? ORDER BY id ASC LIMIT 1";
		Player player = null; 
		try {
			player = run.query(conn,sql, new PlayerHandler(), id);
		} catch (Exception e) {
			log.error(e);
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
		return player;
	}
	public List<Player> getIn(Set<Integer> ids,Connection conn){
		return getIn(ids,conn,TABLE_NAME);
	}
	
	public List<Player> getIn(Set<Integer> ids,Connection conn,String tableName){
		List<Player> players = Lists.newArrayList();
		if(ids.isEmpty()) return players;
		QueryRunner run = new QueryRunner();
		String sql = "SELECT id,create_date,modified_date,uid,language,name,last_login_time,level,exp,vip_level,vip_exp,remark,pre,register_date,recharge_total_diamond FROM " + tableName + " WHERE " + "id in (%s) ORDER BY id ASC";
		sql = String.format(sql, Joiner.on(",").join(ids));
		try {
			players = run.query(conn,sql, new PlayerListHandler());
		} catch (Exception e) {
			log.error(e);
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
		return players;
	}
	/**
	 * 根据( uid ) 查询
	 */
	public Player getByUid(String uid,Connection conn){
		return getByUid(uid,conn,TABLE_NAME);
	}
	
	public Player getByUid(String uid,Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "SELECT id,create_date,modified_date,uid,language,name,last_login_time,level,exp,vip_level,vip_exp,remark,pre,register_date,recharge_total_diamond FROM " + tableName + " WHERE " + "uid = ? ORDER BY id ASC LIMIT 1";
		Player player = null; 
		try {
			player = run.query(conn,sql, new PlayerHandler(), uid);
		} catch (Exception e) {
			log.error(e);
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
		return player;
	}
	/**
	 * 根据( pre ) 查询
	 */
	public List<Player> getByPre(boolean pre,Connection conn){
		return getByPre(pre,conn,TABLE_NAME);
	}
	
	public List<Player> getByPre(boolean pre,Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "SELECT id,create_date,modified_date,uid,language,name,last_login_time,level,exp,vip_level,vip_exp,remark,pre,register_date,recharge_total_diamond FROM " + tableName + " WHERE " + "pre = ? ORDER BY id ASC";
		List<Player> players = Lists.newArrayList();
		try {
			players = run.query(conn, sql, new PlayerListHandler(), pre);
		} catch (Exception e) {
			log.error(e);
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
		return players;
	}
	
	//-----------------------------------page-----------------------------------
	public List<Player> getByPagePre(boolean pre,Connection conn,int page,int pageSize){
		return getByPagePre(pre,conn,TABLE_NAME,page,pageSize);
	}
	
	public List<Player> getByPagePre(boolean pre,Connection conn,String tableName,int page,int pageSize){
		QueryRunner run = new QueryRunner();
		page = ((page-1) * pageSize);
		String sql = "SELECT id,create_date,modified_date,uid,language,name,last_login_time,level,exp,vip_level,vip_exp,remark,pre,register_date,recharge_total_diamond FROM " + tableName + " WHERE " + "pre = ? ORDER BY id ASC LIMIT " + page + " , " +pageSize;
		List<Player> players = Lists.newArrayList();
		try {
			players = run.query(conn, sql, new PlayerListHandler(), pre);
		} catch (Exception e) {
			log.error(e);
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
		return players;
	}
	
	//DataSource
	/**
	 * 根据( id ) 查询
	 */
	public Player getById(int id,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return getById(id, conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public Player getById(int id,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return getById(id, conn, tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	public List<Player> getIn(Set<Integer> ids,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return getIn(ids, conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public List<Player> getIn(Set<Integer> ids,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return getIn(ids, conn, tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	/**
	 * 根据( uid ) 查询
	 */
	public Player getByUid(String uid,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return getByUid(uid, conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public Player getByUid(String uid,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return getByUid(uid, conn, tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	/**
	 * 根据( pre ) 查询
	 */
	public List<Player> getByPre(boolean pre,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return getByPre(pre, conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public List<Player> getByPre(boolean pre,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return getByPre(pre, conn, tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	//-----------------------------------page-----------------------------------
	public List<Player> getByPagePre(boolean pre,DataSource ds,int page,int pageSize){
		try {
			Connection conn = ds.getConnection();
			return getByPagePre(pre, conn,page,pageSize);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public List<Player> getByPagePre(boolean pre,DataSource ds,String tableName,int page,int pageSize){
		try {
			Connection conn = ds.getConnection();
			return getByPagePre(pre, conn,page,pageSize);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	
	public List<Player> getAll(){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getAll(conn);
	}
	
	public List<Player> getAll(Connection conn){
		return getAll(conn,TABLE_NAME);
	}
	
	public List<Player> getAll(DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return getAll(conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public List<Player> getAll(String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getAll(conn,tableName);
	}
	
	public List<Player> getAll(Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "SELECT id,create_date,modified_date,uid,language,name,last_login_time,level,exp,vip_level,vip_exp,remark,pre,register_date,recharge_total_diamond FROM " + tableName + " ORDER BY id ASC";
		List<Player> players = Lists.newArrayList();
		try {
			players = run.query(conn, sql, new PlayerListHandler());
		} catch (Exception e) {
			log.error(e);
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
		return players;
	}
	
	public List<Player> getAll(DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return getAll(conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}		
	}
	
	public List<Player> getAllPage(int page,int pageSize){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getAllPage(conn,page,pageSize);
	}
	
	public List<Player> getAllPage(Connection conn,int page,int pageSize){
		return getAllPage(conn,TABLE_NAME,page,pageSize);
	}
	
	public List<Player> getAllPage(DataSource ds,int page,int pageSize){
		try {
			Connection conn = ds.getConnection();
			return getAllPage(conn,page,pageSize);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public List<Player> getAllPage(String tableName,int page,int pageSize){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getAllPage(conn,tableName,page,pageSize);
	}
	
	public List<Player> getAllPage(Connection conn,String tableName,int page,int pageSize){
		QueryRunner run = new QueryRunner();
		page = ((page-1) * pageSize);
		String sql = "SELECT id,create_date,modified_date,uid,language,name,last_login_time,level,exp,vip_level,vip_exp,remark,pre,register_date,recharge_total_diamond FROM " + tableName + " ORDER BY id ASC LIMIT " + page + " , " +pageSize;
		List<Player> players = Lists.newArrayList();
		try {
			players = run.query(conn, sql, new PlayerListHandler());
		} catch (Exception e) {
			log.error(e);
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
		return players;
	}
	
	public List<Player> getAllPage(DataSource ds,String tableName,int page,int pageSize){
		try {
			Connection conn = ds.getConnection();
			return getAllPage(conn,tableName,page,pageSize);
		} catch (Exception e) {
			log.error(e);
			return null;
		}		
	}
	
	public boolean truncate(){
		Connection conn = DataSourceManager.me().getMainConnection();
		return truncate(conn);
	}
	
	public boolean truncate(Connection conn){
		return truncate(conn,TABLE_NAME);
	}
	
	public boolean truncate(DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return truncate(conn);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	public boolean truncate(String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return truncate(conn,tableName);
	}
	
	public boolean truncate(Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "TRUNCATE " + tableName;
		try {
			run.update(conn, sql);
			return true;
		} catch (Exception e) {
			log.error(e);
			return false;
		} finally {
			try {
				DbUtils.close(conn);
			} catch (Exception e1) {
				log.error(e1);
				return false;
			}
		}
	}
	
	public boolean truncate(DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return truncate(conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	// 执行自定义查询sql
	public List<Map<String,Object>> executeQuerySql(String sql){
		Connection conn = DataSourceManager.me().getMainConnection();
		return executeQuerySql(conn,sql);
	}
	
	public List<Map<String,Object>> executeQuerySql(Connection conn,String sql){
		return executeQuerySql(conn,TABLE_NAME,sql);
	}
	
	public List<Map<String,Object>> executeQuerySql(DataSource ds,String sql){
		try {
			Connection conn = ds.getConnection();
			return executeQuerySql(conn,sql);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public List<Map<String,Object>> executeQuerySql(String tableName,String sql){
		Connection conn = DataSourceManager.me().getMainConnection();
		return executeQuerySql(conn,tableName);
	}
	
	public List<Map<String,Object>> executeQuerySql(Connection conn,String tableName,String sql){
		QueryRunner run = new QueryRunner();
		ToolError.isAndTrue(ArtifactErrorCode.SQL_PERMISSIONS_ERROR, !StrUtil.startWithIgnoreCase(sql, "SELECT"));
		List<Map<String,Object>> list = Lists.newArrayList();
		try {
			list = run.query(conn,sql, new MapListHandler());
		} catch (Exception e) {
			log.error(e);
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
		return list;
	}
	/**
	public List<Map<String,Object>> executeQuerySql(DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return executeQuerySql(conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	*/
	
	//
	
	//
	
	//Drop Table
	public boolean drop(){
		Connection conn = DataSourceManager.me().getMainConnection();
		return drop(conn);
	}
	
	public boolean drop(Connection conn){
		return drop(conn,TABLE_NAME);
	}
	
	public boolean drop(DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return drop(conn);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	public boolean drop(String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return drop(conn,tableName);
	}
	
	public boolean drop(Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "DROP TABLE " + tableName;
		try {
			run.update(conn, sql);
			return true;
		} catch (Exception e) {
			log.error(e);
			return false;
		} finally {
			try {
				DbUtils.close(conn);
			} catch (Exception e1) {
				log.error(e1);
				return false;
			}
		}
	}
	
	public boolean drop(DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return drop(conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	
	//create
	public boolean createTable(CreateTableEnum type){
		Connection conn = DataSourceManager.me().getMainConnection();
		return createTable(conn,type);
	}
	
	public boolean createTable(Connection conn,CreateTableEnum type){
		return createTable(conn,TABLE_NAME,type);
	}
	
	public boolean createTable(DataSource ds,CreateTableEnum type){
		try {
			Connection conn = ds.getConnection();
			return createTable(conn,type);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	public boolean createTable(String tableName,CreateTableEnum type){
		Connection conn = DataSourceManager.me().getMainConnection();
		return createTable(conn,tableName,type);
	}
	
	public boolean createTable(Connection conn,String tableName,CreateTableEnum type){
		QueryRunner run = new QueryRunner();
		SK_Plus plus = SK_Plus.b("CREATE TABLE IF NOT EXISTS `", tableName,"` (");
		plus.a("  `id` INT(11) NOT NULL  COMMENT '',");	
		plus.a("  `create_date` DATETIME NOT NULL  COMMENT '',");
		plus.a("  `modified_date` DATETIME NOT NULL  COMMENT '',");
		plus.a("  `uid` VARCHAR(45)   COMMENT 'remarks=账号ID',");	
		plus.a("  `language` VARCHAR(45)   COMMENT 'remarks=语言',");	
		plus.a("  `name` VARCHAR(45)   COMMENT 'remarks=昵称',");	
		plus.a("  `last_login_time` DATETIME   COMMENT 'remarks=最后登录时间',");
		plus.a("  `level` INT(11) NOT NULL DEFAULT '1' COMMENT 'remarks=等级',");	
		plus.a("  `exp` BIGINT(20)   COMMENT 'remarks=玩家经验',");	
		plus.a("  `vip_level` INT(11)   COMMENT 'remarks=vip等级',");	
		plus.a("  `vip_exp` BIGINT(20)   COMMENT 'remarks=VIP经验',");	
		plus.a("  `remark` VARCHAR(500)   COMMENT 'remarks=宣言',");	
		plus.a("  `pre` TINYINT(1)   COMMENT 'remarks=是否是预创建账号',");	
		plus.a("  `register_date` DATETIME   COMMENT 'remarks=注册时间',");
		plus.a("  `recharge_total_diamond` INT(11)   COMMENT 'remarks=充值总钻石',");	
		plus.a("  PRIMARY KEY (`id`),");
		if (CreateTableEnum.LOGIC.equals(type) || CreateTableEnum.DESIGN.equals(type)) {
			plus.a("  UNIQUE KEY `uid` (`uid`),");
			plus.a("  KEY `pre` (`pre`),");
			
		}
		if (CreateTableEnum.DESIGN.equals(type)) {
			plus.a("  CONSTRAINT `fk_building_player2` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
			plus.a("  CONSTRAINT `fk_city_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
			plus.a("  CONSTRAINT `fk_city_dating_record_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
			plus.a("  CONSTRAINT `fk_shop_buy_record_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
			plus.a("  CONSTRAINT `fk_compose_summon_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
			plus.a("  CONSTRAINT `fk_current_script_record_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
			plus.a("  CONSTRAINT `fk_script_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
			plus.a("  CONSTRAINT `fk_chapter_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
			plus.a("  CONSTRAINT `fk_dungeon_level_group_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
			plus.a("  CONSTRAINT `fk_ElementCollection_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
			plus.a("  CONSTRAINT `fk_formation_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
			plus.a("  CONSTRAINT `fk_hero_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
			plus.a("  CONSTRAINT `fk_item_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
			plus.a("  CONSTRAINT `fk_mail_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
			plus.a("  CONSTRAINT `fk_month_card_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
			plus.a("  CONSTRAINT `fk_table1_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
			plus.a("  CONSTRAINT `fk_player_data_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
			plus.a("  CONSTRAINT `fk_player_shop_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
			plus.a("  CONSTRAINT `fk_recharge_gift_bag_record_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
			plus.a("  CONSTRAINT `fk_order_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
			plus.a("  CONSTRAINT `fk_reserve_date_record_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
			plus.a("  CONSTRAINT `fk_spirit_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
			plus.a("  CONSTRAINT `fk_Task_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
		}
		String sql = plus.e();
		sql = StrUtil.subPre(sql, sql.lastIndexOf(StrUtil.C_COMMA));
		sql+=") ENGINE=InnoDB DEFAULT CHARSET=utf8  COMMENT='remarks=玩家';";
		try {
			run.update(conn, sql);
			return true;
		} catch (Exception e) {
			log.error(e);
			return false;
		} finally {
			try {
				DbUtils.close(conn);
			} catch (Exception e1) {
				log.error(e1);
				return false;
			}
		}
	}
	
	public boolean createTable(DataSource ds,String tableName,CreateTableEnum type){
		try {
			Connection conn = ds.getConnection();
			return createTable(conn,tableName,type);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	
	public String getTableName(){
		return TABLE_NAME;
	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String,Object>> getColumnsInfo(){
		SK_Plus sp = SK_Plus.newSK_Plus();
		sp.a("[");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"NO\",\"TABLE_NAME\":\"player\",\"COLUMN_NAME\":\"id\",\"NULLABLE\":0,\"REMARKS\":\"\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":1,\"DATA_TYPE\":4,\"TYPE_NAME\":\"INT\",\"COLUMN_SIZE\":11}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"NO\",\"TABLE_NAME\":\"player\",\"COLUMN_NAME\":\"create_date\",\"NULLABLE\":0,\"REMARKS\":\"\",\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":2,\"DATA_TYPE\":93,\"TYPE_NAME\":\"DATETIME\",\"COLUMN_SIZE\":19}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"NO\",\"TABLE_NAME\":\"player\",\"COLUMN_NAME\":\"modified_date\",\"NULLABLE\":0,\"REMARKS\":\"\",\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":3,\"DATA_TYPE\":93,\"TYPE_NAME\":\"DATETIME\",\"COLUMN_SIZE\":19}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"player\",\"COLUMN_NAME\":\"uid\",\"NULLABLE\":1,\"REMARKS\":\"remarks=账号ID\",\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":135,\"ORDINAL_POSITION\":4,\"DATA_TYPE\":12,\"TYPE_NAME\":\"VARCHAR\",\"COLUMN_SIZE\":45}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"player\",\"COLUMN_NAME\":\"language\",\"NULLABLE\":1,\"REMARKS\":\"remarks=语言\",\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":135,\"ORDINAL_POSITION\":5,\"DATA_TYPE\":12,\"TYPE_NAME\":\"VARCHAR\",\"COLUMN_SIZE\":45}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"player\",\"COLUMN_NAME\":\"name\",\"NULLABLE\":1,\"REMARKS\":\"remarks=昵称\",\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":135,\"ORDINAL_POSITION\":6,\"DATA_TYPE\":12,\"TYPE_NAME\":\"VARCHAR\",\"COLUMN_SIZE\":45}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"player\",\"COLUMN_NAME\":\"last_login_time\",\"NULLABLE\":1,\"REMARKS\":\"remarks=最后登录时间\",\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":7,\"DATA_TYPE\":93,\"TYPE_NAME\":\"DATETIME\",\"COLUMN_SIZE\":19}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"NO\",\"TABLE_NAME\":\"player\",\"COLUMN_DEF\":\"1\",\"COLUMN_NAME\":\"level\",\"NULLABLE\":0,\"REMARKS\":\"remarks=等级\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":8,\"DATA_TYPE\":4,\"TYPE_NAME\":\"INT\",\"COLUMN_SIZE\":11}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"player\",\"COLUMN_NAME\":\"exp\",\"NULLABLE\":1,\"REMARKS\":\"remarks=玩家经验\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":9,\"DATA_TYPE\":-5,\"TYPE_NAME\":\"BIGINT\",\"COLUMN_SIZE\":20}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"player\",\"COLUMN_NAME\":\"vip_level\",\"NULLABLE\":1,\"REMARKS\":\"remarks=vip等级\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":10,\"DATA_TYPE\":4,\"TYPE_NAME\":\"INT\",\"COLUMN_SIZE\":11}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"player\",\"COLUMN_NAME\":\"vip_exp\",\"NULLABLE\":1,\"REMARKS\":\"remarks=VIP经验\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":11,\"DATA_TYPE\":-5,\"TYPE_NAME\":\"BIGINT\",\"COLUMN_SIZE\":20}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"player\",\"COLUMN_NAME\":\"remark\",\"NULLABLE\":1,\"REMARKS\":\"remarks=宣言\",\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":1500,\"ORDINAL_POSITION\":12,\"DATA_TYPE\":12,\"TYPE_NAME\":\"VARCHAR\",\"COLUMN_SIZE\":500}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"player\",\"COLUMN_NAME\":\"pre\",\"NULLABLE\":1,\"REMARKS\":\"remarks=是否是预创建账号\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":13,\"DATA_TYPE\":-6,\"TYPE_NAME\":\"TINYINT\",\"COLUMN_SIZE\":1}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"player\",\"COLUMN_NAME\":\"register_date\",\"NULLABLE\":1,\"REMARKS\":\"remarks=注册时间\",\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":14,\"DATA_TYPE\":93,\"TYPE_NAME\":\"DATETIME\",\"COLUMN_SIZE\":19}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"player\",\"COLUMN_NAME\":\"recharge_total_diamond\",\"NULLABLE\":1,\"REMARKS\":\"remarks=充值总钻石\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":15,\"DATA_TYPE\":4,\"TYPE_NAME\":\"INT\",\"COLUMN_SIZE\":11}").a(",");
        sp.a("]");
        return JsonManager.me().getJson().parse(sp.e(), List.class);
	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String,Object>> getIndexsInfo(){
		SK_Plus sp = SK_Plus.newSK_Plus();
		sp.a("[");
       	sp.a("{\"NON_UNIQUE\":false,\"TABLE_CAT\":\"dal_game_design\",\"TABLE_NAME\":\"player\",\"COLUMN_NAME\":\"id\",\"INDEX_NAME\":\"PRIMARY\",\"ASC_OR_DESC\":\"A\",\"INDEX_QUALIFIER\":\"dal_game_design\",\"ORDINAL_POSITION\":1,\"CARDINALITY\":0,\"TYPE\":3}").a(",");
       	sp.a("{\"NON_UNIQUE\":false,\"TABLE_CAT\":\"dal_game_design\",\"TABLE_NAME\":\"player\",\"COLUMN_NAME\":\"uid\",\"INDEX_NAME\":\"uid\",\"ASC_OR_DESC\":\"A\",\"INDEX_QUALIFIER\":\"dal_game_design\",\"ORDINAL_POSITION\":1,\"CARDINALITY\":0,\"TYPE\":3}").a(",");
       	sp.a("{\"NON_UNIQUE\":true,\"TABLE_CAT\":\"dal_game_design\",\"TABLE_NAME\":\"player\",\"COLUMN_NAME\":\"pre\",\"INDEX_NAME\":\"pre\",\"ASC_OR_DESC\":\"A\",\"INDEX_QUALIFIER\":\"dal_game_design\",\"ORDINAL_POSITION\":1,\"CARDINALITY\":0,\"TYPE\":3}").a(",");
        sp.a("]");
        return JsonManager.me().getJson().parse(sp.e(), List.class);
	}
//自定义内容起始位置
class PlayerHandler implements ResultSetHandler<Player>{
	@Override
	public Player handle(ResultSet rs) throws SQLException {
		return rs.next() ? Player.builder().createForResultSet(rs).syncIndexValues() : null ;
	}
}

class PlayerListHandler extends AbstractListHandler<Player>{
	@Override
	protected Player handleRow(ResultSet rs) throws SQLException {
		return Player.builder().createForResultSet(rs).syncIndexValues();
	}
}

//自定义内容结束位置
}

